﻿Imports org.codegen.win.controls.Grid
Imports CrystalReportViewer

Namespace Forms.List
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Public Class frmLectureStudentList
        Inherits frmBaseGrid
        Implements IStudentContainingGrid

#Region "Designer"

        'Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub

        Friend WithEvents ucLectureStudentList As ucLectureStudentList

        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer

        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Me.ucLectureStudentList = New IIC.ucLectureStudentList()
            Me.pnlGrid.SuspendLayout()
            Me.SuspendLayout()
            '
            'pnlGrid
            '
            Me.pnlGrid.Controls.Add(Me.ucLectureStudentList)
            Me.pnlGrid.Location = New System.Drawing.Point(0, 53)
            Me.pnlGrid.Size = New System.Drawing.Size(887, 389)
            '
            'ucLectureStudentList
            '
            Me.ucLectureStudentList.Dock = System.Windows.Forms.DockStyle.Fill
            Me.ucLectureStudentList.Location = New System.Drawing.Point(0, 0)
            Me.ucLectureStudentList.Name = "ucLectureStudentList"
            Me.ucLectureStudentList.Size = New System.Drawing.Size(887, 389)
            Me.ucLectureStudentList.TabIndex = 0
            '
            'frmLectureStudentList
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(887, 442)
            Me.Name = "frmLectureStudentList"
            Me.ShowConfigButton = True
            Me.ShowExcelButton = True
            Me.ShowPrintButton = True
            Me.ShowSearch = True
            Me.Text = "Lecture Student List"
            Me.Controls.SetChildIndex(Me.pnlGrid, 0)
            Me.pnlGrid.ResumeLayout(False)
            Me.ResumeLayout(False)

        End Sub

#End Region

#Region "Standard Code"

        Private Sub frmLectureStudentList_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
           Handles Me.Load

            Me.grdData.loadGrid()
            Me.AllowEdit = False 'no need to edit records!
            Me.AllowDeleteMultipleSelection = True

            Dim r As ReportMatadata = My.Application.reportsCache.getSystemReportByKey("1")
            Me.addToReportMenu(r.DisplayName, AddressOf cmdReport1Click, r.ReportKey)

        End Sub

        Protected Sub cmdReport1Click(ByVal sender As Object, ByVal e As EventArgs)

            If Me.grdData.SelectedRows.Count = 0 Then Exit Sub

            Dim r As ReportMatadata = Nothing

            r = My.Application.reportsCache.getSystemReportByKey(CStr(CType(sender, ToolStripMenuItem).Tag))

            Dim cr As CRReportViewer = New CRReportViewer
            cr.ReportMetaData = r
            cr.setCriterionValue("PeriodId", My.Settings.CurrentPeriodId)
            cr.setCriterionValue("LessonId", Me.grdData.SelectedRows(0).Cells("LessonId").Value)
            cr.ShowReport()

        End Sub

        ''' <summary>
        ''' This function is common to all forms that inherit from class frmBaseGrid
        ''' It priovides a common name to the underlying grid control that shows the records
        ''' </summary>
        Public Overrides Function grdData() As org.codegen.win.controls.Grid.CGBaseGrid
            Return Me.ucLectureStudentList.grdLectureStudent
        End Function

        Protected Sub DeleteRecordConfirmed(ByVal sender As System.Object) Handles Me.gridDeleteRecordConfirmed

            Dim m As New LectureStudentDBMapper

            Dim lSender As CGBaseGrid = CType(sender, CGBaseGrid)

            For Each dr As DataGridViewRow In lSender.SelectedRows

                Dim pkValue As Object = lSender.IdValue
                If pkValue IsNot Nothing Then
                    Dim mo As ModelObject = m.findByKey(CInt(pkValue))
                    If mo IsNot Nothing Then
                        Call m.delete(mo)
                    End If
                End If
            Next

        End Sub

        
#End Region



    End Class

End Namespace

